#include "seqlist.h"
#include "linklist.h"
void test_seqlist()
{
    SeqList seqlist;
    seqlist.create(10);
    SeqListNode s1 = (SeqListNode)123;
    SeqListNode s2 = (SeqListNode)124;
    SeqListNode s3 = (SeqListNode)125;
    SeqListNode s4 = (SeqListNode)126;
    seqlist.insert(s1,1);
    seqlist.insert(s2,2);
    seqlist.insert(s3,3);
    seqlist.insert(s4,4);
    seqlist.print();
    cout<<"get:"<<seqlist.getNode(3)<<endl;
    cout<<"locate:"<<seqlist.locate(s3)<<endl;
}

void test_head_insert(SingleLinkList list)
{
    list.headInsert(123);
    list.headInsert(124);
    list.headInsert(125);
    list.headInsert(126);
    list.headInsert(127);
    list.headInsert(128);
    list.traverse();

    cout<<"getNode:"<<list.getNode(0)<<endl;
    cout<<"getNode:"<<list.getNode(1)<<endl;
    cout<<"getNode:"<<list.getNode(2)<<endl;
    cout<<"getNode:"<<list.getNode(3)<<endl;
    cout<<"getNode:"<<list.getNode(4)<<endl;
    cout<<"getNode:"<<list.getNode(5)<<endl;
    cout<<"getNode:"<<list.getNode(6)<<endl;
    cout<<"getNode:"<<list.getNode(7)<<endl;
}

void test_tail_insert(SingleLinkList list)
{
    list.tailInsert(1);
    list.tailInsert(2);
    list.tailInsert(3);
    list.tailInsert(4);
    list.tailInsert(5);
    list.tailInsert(6);
    list.traverse_fortail();
}

void test_singlelinklist()
{
    SingleLinkList list;
//    test_head_insert(list);
    test_tail_insert(list);
}

int main(void)
{
//    test_seqlist();
    test_singlelinklist();
    return 0;
}
